Basic SDK Functions
The functions below are essential to start, stop and communicate with the VPN SDK.
You must have an active user account in order to create a minimum viable VPN product. Press the 'Add a New User' button at https://app.vpnwholesaler.com/users to create one.
At the bare minimum and considering that you already have login credentials for an active VPN account, you should implement the following functions and commands in order to create a minimum viable VPN product:
- Initialize SDK
- Set API domain
- Login
- Set VPN type
- Start VPN connection
- Stop VPN connection
- Finalize SDK
Initialize SDK
Intializes the SDK with a callback and sets necessary path to OpenVPN binary.
Login required: No
Code: InitOVSCore
Input:
vpnsdk = VPNSDKLib()
vpnsdk.InitOVSCore(self)
Response:
int - returns 0 if SDK was intialized sucessfully and other value in case of failure
Finalize SDK
Unloads SDK and finalizes all running threads. It is necessary to call this method before exit to avoid leaks.
Login required: No
Code: FinalizeOVSCore()
Input: None
Response: None
Code sample:
FinalizeOVSCore();
Send command
Asynchronously sends command to SDK. Command result will be returned by calling the callback that was specified on initialization.
All operations in SDK are called asynchronously, and therefore a single callback is used to receive responses from all SDK functions. All responses are encoded as JSON and described in the relevant sections.
Login required: Depending on the command
CmdProc Code: vpnsdk.CmdProc
Input:
{
vpnsdk.CmdProc(CmdProc Code, ["dataObject" : "data"])
}
Response: Generally, responses carry the following JSON structure:
{
"code": integer
"err": integer
"data": { object }
}
Where:
code - the invoked command's notification event. err - error code. data - response based on the notification code.